// index.js

// 获取应用实例
let app = getApp()

Page({
    data: {},

    // 仅执行一次，可用于获取、设置数据
    onLoad () {
        //创建可重复使用的WeToast实例，并附加到this上，通过this.wetoast访问
        new app.WeToast()
    },

    onImgToast () {
        this.wetoast.toast({
            img: '',
            imgClassName: 'my_wetoast_img',
            imgMode: 'scaleToFill'
        })
    },

    onTitleToast () {
        this.wetoast.toast({
            title: 'WeToast',
            //position: 'bottom',
            titleClassName: 'my_wetoast_title'
        })
    },

    onTimeToast () {
        this.wetoast.toast({
            title: 'WeToast',
            duration: 5000
        })
    },

    onFullToast () {
        this.wetoast.toast({
            img: '',
            imgClassName: 'my_wetoast_img',
            imgMode: 'scaleToFill',
            title: 'WeToast',
            titleClassName: 'my_wetoast_title',
            success (data) {
                console.log(Date.now() + ': success')
            },
            fail (data) {
                console.log(Date.now() + ': fail')
            },
            complete (data) {
                console.log(Date.now() + ': complete')
            }
        })
    },

    onCode (e) {
        let type = e.currentTarget.dataset.type
        wx.navigateTo({
            url: `../code/code?type=${type}`
        })
    },

})
